package de.akabahn.ebd.control.data;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author Christian Schlehuber
 * @author Peter Eimann
 * @since 0.1
 * @version 0.2
 */
public class StaticDataStorage {

	public final static String ZDH = "(01) ZDH";
	public final static String ZDP = "(02) ZDP";
	public final static String ZDE = "(03) ZDE";
	public final static String ZDM = "(05) ZDM";
	public final static String ZDS_F = "(06) ZDS-F";
	public final static String ZDS_B = "(07) ZDS-B";
	public final static String ZDA = "(08) ZDA";
	public final static String ZDB = "(09) ZDB";
	public final static String ZDW = "(11) ZDW";
	public final static String ZDMA = "(12) ZDMA";
	public final static String ZDK = "(13) ZDK";
	public final static String ZDEB = "(21) ZDEB";
	public final static String ZDPO = "(22) ZDPO";
	public final static String ZDXFC = "(31) ZDXFC";

	private static StaticDataStorage instance;

	private Map<String, String[]> bahnhoefe;

	private StaticDataStorage() {
		bahnhoefe = new HashMap<String, String[]>();
		initialize();
	}

	private void initialize() {
		String[] zdh = {"1", "2", "11", "12", "21", "22", "102", "301", "302", "303", "304"};
		String[] zdp = {"1", "2", "3", "4", "5"};
		String[] zde = {"1", "2", "3", "21", "B902"};
		String[] zdm = {"1", "2", "3", "4"};
		String[] zds_f = {"1", "2", "3", "21", "22", "32"};
		String[] zds_b = {"1", "3", "13", "14", "23", "24", "25", "26"};
		String[] zda = {"1", "2", "3"};
		String[] zdb = {"1", "2", "11", "12", "101", "102", "103", "104", "105", "106", "121"};
		String[] zdw = {"2", "3", "4", "5", "6", "23"};
		String[] zdma = {"1", "2", "4", "5", "6", "7"};
		String[] zdk = {"1", "2", "3"};
		String[] zdeb = {"1", "2", "3"};
		String[] zdpo = {"1", "2"};
		String[] zdxfc = {"1", "2", "11", "12", "13"};

		bahnhoefe.put(ZDH, zdh);
		bahnhoefe.put(ZDP, zdp);
		bahnhoefe.put(ZDE, zde);
		bahnhoefe.put(ZDM, zdm);
		bahnhoefe.put(ZDS_F, zds_f);
		bahnhoefe.put(ZDS_B, zds_b);
		bahnhoefe.put(ZDA, zda);
		bahnhoefe.put(ZDB, zdb);
		bahnhoefe.put(ZDW, zdw);
		bahnhoefe.put(ZDMA, zdma);
		bahnhoefe.put(ZDK, zdk);
		bahnhoefe.put(ZDEB, zdeb);
		bahnhoefe.put(ZDPO, zdpo);
		bahnhoefe.put(ZDXFC, zdxfc);
	}

	public static StaticDataStorage getInstance() {
		if (instance == null) {
			instance = new StaticDataStorage();
		}

		return instance;
	}

	public List<String> getBahnhoefe() {
		List<String> result = null;
		result = new ArrayList<String>();
		result.addAll(bahnhoefe.keySet());
		return result;
	}

	public String[] getGleise(String bahnhof) {
		return bahnhoefe.get(bahnhof);
	}

	public String getBahnhofNummer(String bahnhof) {
		return bahnhof.substring(1, 3);
	}
}
